package derk.ui;

import java.text.SimpleDateFormat;

import javax.swing.ImageIcon;

import derk.sam.IDCardData;

public class DerkUI extends javax.swing.JFrame {
	private static final long serialVersionUID = 1L;
	private static javax.swing.JLabel jLabel1;
	private static javax.swing.JLabel label1;
	private static javax.swing.JLabel label2;
	private static javax.swing.JLabel label3;
	private static javax.swing.JLabel label4;
	private static javax.swing.JLabel label5;
	private static javax.swing.JLabel label6;
	private static java.awt.TextField textBirth;
	private static java.awt.TextField textFolk;
	private static java.awt.TextField textID;
	private static java.awt.TextField textName;
	private static java.awt.TextArea textReport;
	private static java.awt.TextField textAddress;
	private static java.awt.TextField textSex;
	
	public DerkUI () {
		initComponents();
	}
	
	private void initComponents() {

		label1 = new javax.swing.JLabel();
		label2 = new javax.swing.JLabel();
		label3 = new javax.swing.JLabel();
		label4 = new javax.swing.JLabel();
		label5 = new javax.swing.JLabel();
		label6 = new javax.swing.JLabel();
		textID = new java.awt.TextField();
		textName = new java.awt.TextField();
		textSex = new java.awt.TextField();
		textFolk = new java.awt.TextField();
		textBirth = new java.awt.TextField();
		textAddress = new java.awt.TextField();
		jLabel1 = new javax.swing.JLabel();
		textReport = new java.awt.TextArea();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("DKCloudID Demo");
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
		setIconImage(getToolkit().getImage("/HXGK_JavaDemo.ico"));
		setLocationByPlatform(true);
		setMinimumSize(new java.awt.Dimension(380, 660));
		setResizable(false);
		getContentPane().setLayout(
				new org.netbeans.lib.awtextra.AbsoluteLayout());

		label1.setText("\u59d3\u540d\uff1a");
		getContentPane().add(
				label1,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1,
						-1));

		label2.setText("\u6027\u522b\uff1a");
		getContentPane().add(
				label2,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1,
						-1));

		label3.setText("\u6c11\u65cf\uff1a");
		getContentPane().add(
				label3,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1,
						-1));

		label4.setText("\u51fa\u751f\u65e5\u671f\uff1a");
		getContentPane().add(
				label4,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1,
						-1));

		label5.setText("住址：");
		getContentPane().add(
				label5,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, -1,
						-1));

		label6.setText("\u8eab\u4efd\u8bc1\u53f7\uff1a");
		getContentPane().add(
				label6,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, -1,
						-1));
		getContentPane().add(
				textID,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 180, 130,
						-1));
		getContentPane().add(
				textName,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 20, 130,
						-1));
		getContentPane().add(
				textSex,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 60, 130,
						-1));
		getContentPane().add(
				textFolk,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 100, 130,
						-1));
		getContentPane().add(
				textBirth,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 140, 130,
						-1));
		getContentPane().add(
				textAddress,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 220, 280,
						-1));

		jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
		getContentPane().add(
				jLabel1,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 20, 100,
						130));
		getContentPane().add(
				textReport,
				new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 260, 360,
						390));

		pack();
	}
	
	public void logView(String s) {
		//jArea.append(s + "\r\n");
	}
	
	public static void logViewln(String s) {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		//jArea.append("\r\n<" + df.format(System.currentTimeMillis()) + "> " + s);
		textReport.append("\r\n<" + df.format(System.currentTimeMillis()) + "> " + s);
		if (textReport.getText().length() > 10000) {
			textReport.setText("");
		}
	}
	
	public static void showIDMsg(IDCardData iDCardData) {
		if (iDCardData == null) {
			textID.setText("");
			textBirth.setText("");
			textName.setText("");
			textSex.setText("");
			textFolk.setText("");
			textAddress.setText("");
			jLabel1.setText("");
			jLabel1.setIcon(new ImageIcon());
		}
		else {
			textID.setText(iDCardData.IDCardNo);
			textBirth.setText(iDCardData.Born);
			textName.setText(iDCardData.Name);
			textSex.setText(iDCardData.Sex);
			textFolk.setText(iDCardData.Nation);
			textAddress.setText(iDCardData.Address);
			jLabel1.setIcon(new ImageIcon(iDCardData.image));
		}
	}
}













